package cr2;

import java.io.File;
import java.util.ArrayList;
import java.util.ListIterator;
import tools.SseoTools;

/**
 * @author Kevin
 * implement 
 * DOS robocopy /MOVE /S 
 * X:\Kevin\Pictures\[NEW] 
 * X:\Kevin\Pictures\[RAW]\WORKING *.CR2
 * 
 * @param args 
 */
public class CR2Mover {

	final static String srcFolderBaseFP = "X:\\Kevin\\Pictures\\[NEW]";
	final static String dstFolderBaseFP = "X:\\Kevin\\Pictures\\[RAW]\\Working";


	public static void main(String[] args) {
		// TODO Auto-generated method stub

		SseoTools sseoTools = new SseoTools();  
		File srcBaseFolder = new File(srcFolderBaseFP);
		
		ArrayList<String> listSub = 
			sseoTools.listSubFolderOnly(srcBaseFolder.getPath());
		
		ListIterator<String> litr = listSub.listIterator();
		
		System.out.println(listSub.size());
				
		while (litr.hasNext()) {
			String folder = (String) litr.next(); 
			File srcChildFolder = new File(srcFolderBaseFP,folder );
			File destChildFolder = new File(dstFolderBaseFP,folder );

			System.out.println(srcChildFolder.getPath());
			System.out.println(destChildFolder.getPath());
			
			if (!destChildFolder.exists()) {
				destChildFolder.mkdir();
			}
			
			File[] files = srcChildFolder.listFiles(sseoTools
					.fileFilterExt("CR2"));
			
			for (File file : files) {
				System.out.println(file.getPath());
				sseoTools.moveFile(file.getPath(), destChildFolder.getPath());
			}

		}
	}
}
